]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Improving dependency management
authorJean-Marc Pigeon <jmp@safe.c>
Mon, 3 Nov 2025 14:45:01 +0000 (09:45 -0500)
committerJean-Marc Pigeon <jmp@safe.c>
Mon, 3 Nov 2025 14:45:01 +0000 (09:45 -0500)
.gitignore
Makefile
app/Makefile
lib/Makefile
sql/Makefile
tools/Makefile

index 804ba00385ab52de54ea2cb1e0e054c3097fa1d4..a0a52243be77796869708d16e7bb3c01a2e6d3fc 100644 (file)
@@ -4,6 +4,7 @@ data-sender/
 data-sorter/
 data-sorter2/
 *.swp
+*.d
 bin
 shared/
 lib/numver.h
index 69ac4af59c3d0a10b7db5befb75491ec97143b09..c96d47688a1acddb42f0fc005787d5e58ee69ee8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,11 +15,11 @@ debug                                                       \
        :
           @ for i in $(SUBDIR) ;                       \
               do                                       \
-              $(MAKE) DB=$(DB) -s -C $$i $@ ;          \
+              $(MAKE) DB=$(DB) -C $$i $@ ;             \
               done
        
        
-
+allclean                                               \
 clean  :  cleanrpm
           @ for i in $(SUBDIR) ;                       \
               do                                       \
index 39d89d1de75be5340c14d9b8df30520bff002c92..dcc84b1277d1ce864f9aa9e3b1fc00ffa9a8defb 100644 (file)
@@ -17,6 +17,9 @@ clean :
           - rm -fr *.o $(EXE)
           - rm -fr ../bin-*
 
+allclean:  clean
+          - rm -fr *.d
+
 #--------------------------------------------------------------------
 #Equivalences
 #--------------------------------------------------------------------
@@ -140,8 +143,25 @@ toremake:  Makefile
           @ - mkdir -p ../bin-utils
           @ - mkdir -p ../bin-posql
           @ - mkdir -p ../bin-mysql
-          - rm -f $(EXE) *.o
+          - rm -f $(EXE) *.o
 
 #--------------------------------------------------------------------
-.PHONY:   toremake
+#to manage dependencies
+%.d:     %.c
+         @ set -e; rm -f $@;                                   \
+           $(CC) -I ../lib -M $(CPPFLAGS) $< > $@.$$$$;        \
+           sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+           rm -f $@.$$$$
+
+sources        =                                                       \
+           chkspf.c                                            \
+           feeder.c                                            \
+           receiver.c                                          \
+           scanner.c                                           \
+           sender.c                                            \
+           sorter.c                                            \
+
+include $(sources:.c=.d)
+#--------------------------------------------------------------------
+.PHONY:   toremake clean allclean
 #--------------------------------------------------------------------
index 2dc97d84570f9b38e2ffd55f39f9edb99873e00e..9a857ab4e54c2699c3cdaee5466c63d66ac34aca 100644 (file)
@@ -15,6 +15,9 @@ prod  :  toremake
 clean  :
           - rm -fr *.so.* *.o *.a *.tar.gz
 
+allclean:  clean
+          - rm -fr *.d
+
 #--------------------------------------------------------------------
 #Equivalences
 #--------------------------------------------------------------------
@@ -35,6 +38,7 @@ objs  : $(OBJS) $(LIBS)
 
 #--------------------------------------------------------------------
 #Dependances
+modrec.d                                       \
 modrec.o:                                      \
           subrou.h                             \
           uniprc.h                             \
@@ -43,22 +47,26 @@ modrec.o:                                   \
           gestcp.h                             \
           modrec.h modrec.c
 
+lvleml.d                                       \
 lvleml.o:                                      \
           subcnv.h subrou.h                    \
           unidig.h unidns.h unieml.h uniprc.o  \
           gestcp.h gessql.h                    \
           lvleml.h lvleml.c
 
+gesspf.d                                       \
 gesspf.o:                                      \
           subrou.h                             \
           gesspf.h gesspf.h
 
+geseml.d                                       \
 geseml.o:                                      \
           subrou.h                             \
           unidns.h unieml.h unipar.h unitls.h  \
           devsql.h                             \
           geseml.h geseml.h
 
+gestcp.d                                       \
 gestcp.o:                                      \
           subrou.h                             \
           unieml.h                             \
@@ -66,6 +74,7 @@ gestcp.o:                                     \
           unisig.h                             \
           gestcp.h gestcp.c
 
+gessql.d                                       \
 gessql.o:                                      \
           unisql.h                             \
           devsql.h                             \
@@ -191,13 +200,31 @@ libmar.a:  unipos.o                               \
          @ ar -cr libmar.a libmar.o unipos.o
 
 #--------------------------------------------------------------------
-
 toremake:  Makefile
           touch toremake
           - rm -f $(OBJS) $(LIBMAIL)
 
 #--------------------------------------------------------------------
-.PHONY:        clean
+#to manage dependencies
+%.d:     %.c
+         @ set -e; rm -f $@;                                   \
+           $(CC) -M $(CPPFLAGS) $< > $@.$$$$;                  \
+           sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+           rm -f $@.$$$$
+
+sources        =                                                       \
+           modrec.c                                            \
+           lvleml.c                                            \
+           geseml.c gesspf.c gessql.c gestcp.c                 \
+           devlog.c devsoc.c devsql.c                          \
+           unidig.c unidns.c unieml.c unimar.c                 \
+           unipar.c unipos.c uniprc.c unisig.c                 \
+           unisql.c unitls.c                                   \
+           subafn.c subcnv.c subrou.c                          \
+
+include $(sources:.c=.d)
+#--------------------------------------------------------------------
+.PHONY:        clean allclean
 #--------------------------------------------------------------------
 CC     = gcc
 LD     = gcc
index ed1208fd4b086d1068d2990e7053d8984152a25d..86d3b8f61c7154cdbbcf77b148464e5531445f45 100644 (file)
@@ -5,6 +5,7 @@ prod                                            \
 debug                                          \
        :  mailleur.postg mailleur.mysql
 
+allclean                                       \
 clean  :  
           @ rm -fr mailleur.mysql mailleur.postg
 
index ed16040ca4a5966d5835ae31425c3274e39aa14f..76622082e3de0e951f1c6d96969cfecc767d419d 100644 (file)
@@ -12,7 +12,7 @@ prod  :
 exe    :
           $(MAKE) $(EXE)
 
-
+allclean                                               \
 clean  :
           - rm -fr *.o $(EXE) toremake
           - rm -fr ../bin/*