Commit d4228955c5d48d4dd43026a8c5a02b08f4e50a27
authorMichel Pollet <buserror@gmail.com>
Tue, 15 Aug 2017 10:14:48 +0000 (11:14 +0100)
committerMichel Pollet <buserror@gmail.com>
Tue, 15 Aug 2017 10:14:48 +0000 (11:14 +0100)
Removed duplicate make commands for libraries

Signed-off-by: Michel Pollet <buserror@gmail.com>
3 files changed:
Makefile.common
examples/parts/Makefile
simavr/Makefile

index 840a98e22898b1f976667eb4335818b8a07075d9..9b56e27606928699bcef2d9d8e42dbf940c809e6 100644 (file)
@@ -184,12 +184,39 @@ ${OBJ}/%.elf:
 ifneq ($(E),)
        @echo LD $@
 endif
-       ${E}$(CC) -MMD ${CFLAGS}  ${LFLAGS} -o $@ $^ $(LDFLAGS)
+       ${E}$(CC) -MMD ${CFLAGS}  ${LFLAGS} -o $@ ${filter %.o,$^} $(LDFLAGS)
+
+
+.PRECIOUS: ${OBJ}/%.a ${OBJ}/%.so.1
+#
+# Static library
+#
+${OBJ}/%.a:
+ifneq ($(E),)
+       @echo AR $@
+endif
+       ${E}$(AR) cru $@ ${filter %.o,$^} && $(RANLIB) $@
+
+#
+# Shared library (Linux)
+#
+${OBJ}/%.so.1: ${OBJ}/%.a
+ifneq ($(E),)
+       @echo SHARED $@
+endif
+       ${E}$(CC) -o $@ -shared \
+               -Wl,--whole-archive,-soname,${basename ${notdir $@}}.1 \
+               ${filter %.o %.a,$^} \
+                -Wl,--no-whole-archive \
+               ${filter-out -l%, $(LDFLAGS)} ${EXTRA_LDFLAGS}
+
+${OBJ}/%.so: ${OBJ}/%.so.1
+       ln -sf ${notdir $<} $@
 
 obj: ${OBJ}
 
 ${OBJ}:
-       @mkdir -p ${OBJ}
+       ${E}mkdir -p ${OBJ}
 
 clean-${OBJ}:
        rm -rf ${OBJ}
index 371137969b36aaf4ae0c43a0753df48c9029d7e9..153e64f32e3b1a11b21d76f43fe2b1a7b7d61bca 100644 (file)
@@ -38,25 +38,14 @@ endif
 #
 # Static library
 #
-static_lib = $(target).a
-
-${OBJ}/${static_lib} : ${objects}
-${OBJ}/${static_lib} :
-       $(AR) cru $@ $^
-${target}: ${OBJ}/${static_lib}
-
+${OBJ}/${target}.a: ${objects}
+${target}: ${OBJ}/${target}.a
 #
 # Shared library (Linux only)
 #
-shared_lib = ${target}.so.1
-
-${OBJ}/${shared_lib} : ${objects}
-${OBJ}/${shared_lib} :
-       ${CC} -shared -Wl,-soname,${shared_lib} $^ -o $@
 ifeq (${shell uname}, Linux)
-${target}: ${OBJ}/${shared_lib}
+${target}: ${OBJ}/${target}.so
 endif
-       @echo $@ done
 
 clean: clean-${OBJ}
        rm -rf *.hex *.a *.axf *.vcd .*.swo .*.swp .*.swm .*.swn *.so *.o
index 09f7fcdfe5238d1f898f3c29c731034f478b4d47..c4e009d2fff46ea6a17974dc599cb01dd35a255e 100644 (file)
@@ -50,23 +50,7 @@ IPATH        += ../../shared
 # Static library
 #
 ${OBJ}/libsimavr.a     :       ${sim_o}
-ifneq ($(E),)
-       @echo AR $@
-endif
-       ${E}$(AR) cru $@ $^ && $(RANLIB) $@
-
-#
-# Shared library (Linux)
-#
-${OBJ}/libsimavr.so.1  :       ${sim_o}
-ifneq ($(E),)
-       @echo SHARED $@
-endif
-       ${E}$(CC) -shared -Wl,-soname,libsimavr.so.1 -o $@ $^ \
-               ${filter-out -lsimavr, $(LDFLAGS)}
 
-${OBJ}/libsimavr.so            : ${OBJ}/libsimavr.so.1
-       ln -sf libsimavr.so.1 $@
 
 libsimavr      : config ${OBJ}/libsimavr.a
 # shared library won't work that easily on non-linux
@@ -74,6 +58,7 @@ ifeq (${shell uname}, Linux)
 libsimavr      : ${OBJ}/libsimavr.so
 endif
 
+${OBJ}/${target}.elf   : libsimavr
 ${OBJ}/${target}.elf   : ${OBJ}/${target}.o
 
 ${target}      : ${OBJ}/${target}.elf
@@ -168,7 +153,6 @@ sim_core_config.h ${OBJ}/cores.deps: $(cores) Makefile
                        conf+="#define CONFIG_$$upper 1\n"; \
                        obj=$${file/.c/.o} ; obj=$${obj/cores\/}; \
                        printf "\$${OBJ}/libsimavr.a: \$${OBJ}/$$obj\n">>${OBJ}/cores.deps ; \
-                       printf "\$${OBJ}/libsimavr.so.1: \$${OBJ}/$$obj\n">>${OBJ}/cores.deps ; \
                else \
                        conf+="#undef CONFIG_$$upper\n"; \
                        echo WARNING $$file did not compile, check your avr-gcc toolchain; \