From 24aa0b2ab1913f0c825b8eca43fb0b392968a2ee Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Mon, 6 Sep 2021 15:36:12 +0200
Subject: [PATCH] LDFLAGS hopefully correctly positioned

---
 Makefile                    | 2 +-
 plugins/comedi/Makefile     | 2 +-
 plugins/libtest/Makefile    | 2 +-
 plugins/serial2002/Makefile | 2 +-
 test/Makefile               | 6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 7960c69..05c50f9 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ build/lib build:
 	mkdir -p $@
 
 %:	build/%.o Makefile
-	$(CC) $(LDFLAGS) $(LDFLAGS_$(*)) -o $@  $(filter %.o,$^)
+	$(CC) -o $@  $(filter %.o,$^) $(LDFLAGS) $(LDFLAGS_$(*))
 
 build/%.o:	%.c Makefile
 	$(CC) $(CCFLAGS) -c -o $@ $<
diff --git a/plugins/comedi/Makefile b/plugins/comedi/Makefile
index f19f0f3..8975d5a 100644
--- a/plugins/comedi/Makefile
+++ b/plugins/comedi/Makefile
@@ -6,7 +6,7 @@ LDFLAGS_comedi=-shared -fPIC -L../../build -lmoberg -lcomedi -lm
 all:	$(LIBRARIES:%=build/%)
 
 build/libmoberg_%.so: build/%.o Makefile | build
-	$(CC) $(LDFLAGS) $(LDFLAGS_$(*)) -o $@ $(filter %.o,$^)
+	$(CC) -o $@ $(filter %.o,$^) $(LDFLAGS) $(LDFLAGS_$(*))
 
 .PRECIOUS: build/%.o
 build/%.o:      %.c Makefile | build
diff --git a/plugins/libtest/Makefile b/plugins/libtest/Makefile
index aeb43e2..ad96bc0 100644
--- a/plugins/libtest/Makefile
+++ b/plugins/libtest/Makefile
@@ -6,7 +6,7 @@ LDFLAGS_libtest=-shared -fPIC -L../../build -lmoberg
 all:	$(LIBRARIES:%=build/%)
 
 build/libmoberg_%.so: build/%.o Makefile | build
-	$(CC) $(LDFLAGS) $(LDFLAGS_$(*)) -o $@ $(filter %.o,$^)
+	$(CC) -o $@ $(filter %.o,$^) $(LDFLAGS) $(LDFLAGS_$(*))
 
 .PRECIOUS: build/%.o
 build/%.o:      %.c Makefile | build
diff --git a/plugins/serial2002/Makefile b/plugins/serial2002/Makefile
index b366d12..f2a2caa 100644
--- a/plugins/serial2002/Makefile
+++ b/plugins/serial2002/Makefile
@@ -6,7 +6,7 @@ LDFLAGS_serial2002=-shared -fPIC -L../../build -lmoberg
 all:	$(LIBRARIES:%=build/%)
 
 build/libmoberg_%.so: build/%.o Makefile | build
-	$(CC) $(LDFLAGS) $(LDFLAGS_$(*)) -o $@ $(filter %.o,$^)
+	$(CC) -o $@ $(filter %.o,$^) $(LDFLAGS) $(LDFLAGS_$(*))
 
 .PRECIOUS: build/%.o
 build/%.o:      %.c Makefile | build
diff --git a/test/Makefile b/test/Makefile
index 50ee3e2..50a8391 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -9,8 +9,8 @@ ENV_TEST = LD_LIBRARY_PATH=../build \
 	   JULIA_LOAD_PATH=../adaptors/julia
 LDFLAGS_test_moberg4simulink = -lmoberg4simulink
 CCFLAGS_test_moberg4simulink = -I../adaptors/matlab -Wall -Werror -I$(shell pwd) -g
-PYTHON2PATH=$(shell realpath ../adaptors/python/install/usr/lib*/python2*/site-packages)
-PYTHON3PATH=$(shell realpath ../adaptors/python/install/usr/lib*/python3*/site-packages)
+PYTHON2PATH=$(shell realpath ../adaptors/python2/install/usr/lib*/python2*/site-packages)
+PYTHON3PATH=$(shell realpath ../adaptors/python3/install/usr/lib*/python3*/site-packages)
 all:
 
 .PHONY: test
@@ -34,7 +34,7 @@ run_jl_%: %.jl
 .PRECIOUS: build/%
 
 build/%: %.c | build
-	$(CC) $(CCFLAGS) $(CCFLAGS_$*) $(LDFLAGS) $(LDFLAGS_$*) -o $@ $<
+	$(CC) $(CCFLAGS) $(CCFLAGS_$*) -o $@ $< $(LDFLAGS) $(LDFLAGS_$*)
 
 build:
 	mkdir build
-- 
GitLab