]> andersk Git - moira.git/blobdiff - util/imake.includes/Imake.rules
add mk_cmds
[moira.git] / util / imake.includes / Imake.rules
index 2b5ced42067cf8338b4402845cb8279c5a3b1f76..1a983041a978669b31421a038cd5fd61f8d1771b 100644 (file)
@@ -7,21 +7,24 @@
 #define concat(x,y) x##y
 #define concat3(x,y,z) x##y##z
 #define concat4(w,x,y,z) w##x##y##z
+#define concat5(v,w,x,y,z) v##w##x##y##z
 #define requote(x) #x
 #else
-#define concat(x,y) x/**/y
-#define concat3(x,y,z) x/**/y/**/z
-#define concat4(w,x,y,z) w/**/x/**/y/**/z
+#define concat(x,y)x/**/y
+#define concat3(x,y,z)x/**/y/**/z
+#define concat4(w,x,y,z)w/**/x/**/y/**/z
+#define concat5(v,w,x,y,z)v/**/w/**/x/**/y/**/z
 #define requote(x) "x"
 #endif
 
+#ifdef PROFILED_LIBS
 /*
  * Rule for building objects in libraries.
  */
 
 #define library_obj_rule()                                             @@\
 .c.o:                                                                  @@\
-       $(CC) -p -c $(CFLAGS) $*.c                                      @@\
+       $(CC) PROF_FLAG -c $(CFLAGS) $*.c                               @@\
        -$(LD) -X -r -o profiled/$*.o $*.o                              @@\
        $(CC) -c $(CFLAGS) $*.c                                         @@\
        -$(LD) -x -r -o a.out $*.o                                      @@\
@@ -34,7 +37,7 @@
 
 #define library_ro_object(cfile)                                       @@\
 concat(cfile,.o): concat(cfile,.c)                                     @@\
-       $(CC) -p -c $(CFLAGS) concat(cfile,.c)                          @@\
+       $(CC) PROF_FLAG -c $(CFLAGS) concat(cfile,.c)                   @@\
        -$(LD) -X -r -o profiled/$*.o $*.o                              @@\
        $(CCRO) -c $(CFLAGS) concat(cfile,.c)                           @@\
        -$(LD) -x -r -o a.out $*.o                                      @@\
@@ -65,20 +68,72 @@ concat3(lib,libname,_p.a): objs                                             @@\
 lint:: concat3(llib-l,libname,.ln)                                     @@\
                                                                        @@\
 concat3(llib-l,libname,.ln): srcs                                      @@\
-       $(LINT) concat(-C,libname) $(CFLAGS) srcs lintlibs              @@\
+       $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs           @@\
                                                                        @@\
 clean::                                                                @@\
        $(RM) concat3(lib,libname,.a) concat3(lib,libname,_p.a)         @@\
        $(RM) concat3(llib-l,libname,.ln)                               @@\
        $(RM) objs                                                      @@\
-       $(RM) profiled\/*.o                                             @@\
+       $(RM) profiled/?*.o                                             @@\
                                                                        @@\
 install::                                                              @@\
-       $(INSTALLFILE) concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)     @@\
-       $(RANLIB) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)          @@\
-       $(INSTALLFILE) concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a) @@\
-       $(RANLIB) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a)                @@\
-       $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LIBDIR)/lint,llib-l,libname,.ln) @@\
+       $(INSTALLRAW) -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)       @@\
+       $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)       @@\
+       $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)       @@\
+       $(INSTALLRAW) -m 644 concat3(lib,libname,_p.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a)   @@\
+       $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a)     @@\
+       $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,_p.a)     @@\
+       $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBDIR)/,llib-l,libname,.ln) @@\
+
+#else /* !PROFILED_LIBS */
+/*
+ * Rule for building objects in libraries.
+ */
+
+#define library_obj_rule()                                             @@\
+.c.o:                                                                  @@\
+       $(CC) -c $(CFLAGS) $*.c                                         @@\
+       -$(LD) -x -r -o a.out $*.o                                      @@\
+       $(MV) a.out $*.o
+
+#define library_ro_object(cfile)                                       @@\
+concat(cfile,.o): concat(cfile,.c)                                     @@\
+       $(CCRO) -c $(CFLAGS) concat(cfile,.c)                           @@\
+       -$(LD) -x -r -o a.out $*.o                                      @@\
+       $(MV) a.out $*.o
+
+#define library_asm_object(ofile,sfile)                                        @@\
+ofile: sfile                                                           @@\
+       $(CPP) x.c | $(AS) -                                            @@\
+       -$(LD) -x -r -o $*.o a.out                                      @@\
+       $(RM) a.out x.c
+
+#define        install_library_target(libname,objs,srcs,lintlibs)              @@\
+                                                                       @@\
+all:: concat3(lib,libname,.a)                                          @@\
+all:: concat3(llib-l,libname,.ln)                                      @@\
+                                                                       @@\
+concat3(lib,libname,.a): objs                                          @@\
+       $(ARCHIVE) $@ objs                                              @@\
+       $(RANLIB) $@                                                    @@\
+                                                                       @@\
+lint:: concat3(llib-l,libname,.ln)                                     @@\
+                                                                       @@\
+concat3(llib-l,libname,.ln): srcs                                      @@\
+       $(LINT) concat(-C,libname) $(LINTFLAGS) srcs lintlibs           @@\
+                                                                       @@\
+clean::                                                                @@\
+       $(RM) concat3(lib,libname,.a)                                   @@\
+       $(RM) concat3(llib-l,libname,.ln)                               @@\
+       $(RM) objs                                                      @@\
+                                                                       @@\
+install::                                                              @@\
+       $(INSTALLRAW) -m 644 concat3(lib,libname,.a) concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)       @@\
+       $(RANLIB) -t concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)       @@\
+       $(CHMOD) 444 concat4($(DESTDIR)$(LIBDIR)/,lib,libname,.a)       @@\
+       $(INSTALLFILE) concat3(llib-l,libname,.ln) concat4($(DESTDIR)$(LINTLIBBDIR)/,llib-l,libname,.ln)        @@\
+
+#endif /* PROFILED_LIBS */
 
 /*
  * Rule for building utilities (binaries which don't get installed)
@@ -87,7 +142,7 @@ install::                                                            @@\
 all:: pgm                                                              @@\
                                                                        @@\
 pgm: objs localdeps                                                    @@\
-       $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
+       $(CC) $(CFLAGS) -o $@ objs syslibs                              @@\
                                                                        @@\
 clean::                                                                @@\
        $(RM) pgm objs                                                  @@\
@@ -131,18 +186,36 @@ clean::                                                                   @@\
  * Rule for compileing files with "et"
  */
 
-#define comp_et(src)                                                   @@\
-concat(src,.h):: concat(src,.et)                                       @@\
-       compile_et concat(src,.et)                                      @@\
-concat(src,.o):: concat(src,.et)                                       @@\
-       compile_et concat(src,.et)                                      @@\
+#ifdef PROFILED_LIBS
+#define comp_et_prof(tbl)                                              @@\
+concat(tbl,.h) concat(tbl,.o): concat(tbl,.et)                         @@\
+       $(COMPILE_ET) concat(tbl,.et) -n                                @@\
+       $(CC) -c PROF_FLAG concat(tbl,.et.c)                            @@\
+       $(MV) concat(tbl,.et.o) concat3(profiled/,tbl,.o)               @@\
+       $(COMPILE_ET) concat(tbl,.et)                                   @@\
 clean::                                                                        @@\
        $(RM) concat(src,.o) concat(src,.h)                             @@\
+depend:: concat(src,.h)
+#else /* !PROFILED_LIBS */
+#define comp_et_prof(tbl) comp_et(tbl)
+#endif /* PROFILED_LIBS */
+
+#define comp_et(tbl)                                                   @@\
+concat(tbl,.h) concat(tbl,.o): concat(tbl,.et)                         @@\
+       $(COMPILE_ET) concat(tbl,.et)                                   @@\
+clean::                                                                        @@\
+       $(RM) concat(src,.o) concat(src,.h)
 
 #define comp_et_depend(src)                                            @@\
        comp_et(src)                                                    @@\
                                                                        @@\
-depend:: concat(src,.h)                                                        @@\
+depend:: concat(src,.h)
+
+#define mk_cmds(tbl)                                                   @@\
+concat(tbl,.o): concat(tbl,.ct)                                                @@\
+       $(MAKE_COMMANDS) concat(tbl,.ct)                                @@\
+clean::                                                                        @@\
+       $(RM) concat(src,.o)
 
 /*
  * Rule for building some random object module
@@ -226,7 +299,7 @@ clean::                                                             @@\
 all:: pgm                                                              @@\
                                                                        @@\
 pgm: objs localdeps                                                    @@\
-       $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
+       $(CC) $(CFLAGS) -o $@ objs syslibs                              @@\
                                                                        @@\
 install::                                                              @@\
        $(INSTALLSUID) pgm ${DESTDIR}installdir/pgm                     @@\
@@ -242,7 +315,7 @@ clean::                                                             @@\
 all:: pgm                                                              @@\
                                                                        @@\
 pgm: objs localdeps                                                    @@\
-       $(CC) $(CFLAGS) -o $@ objs localdeps syslibs                    @@\
+       $(CC) $(CFLAGS) -o $@ objs syslibs                              @@\
                                                                        @@\
 install::                                                              @@\
        $(INSTALLRAW) instopts pgm ${DESTDIR}installdir/pgm             @@\
@@ -250,6 +323,26 @@ install::                                                          @@\
 clean::                                                                @@\
        $(RM) pgm objs                                                  @@\
 
+/*
+ * Special rule for building and installing a Berkeley r-command
+ * We need to preserve the original copies upon installation.
+ */
+
+#define ucbprogram(pgm,objs,localdeps,syslibs,installdir)              @@\
+all:: pgm                                                              @@\
+                                                                       @@\
+pgm: objs localdeps                                                    @@\
+       $(CC) $(CFLAGS) -o $@ objs syslibs                              @@\
+                                                                       @@\
+install::                                                              @@\
+       if [ ! -f concat5(${DESTDIR},installdir,/,pgm,.ucb) -a -f concat4(${DESTDIR},installdir,/,pgm) ]; then \ @@\
+               mv concat4(${DESTDIR},installdir,/,pgm) concat5(${DESTDIR},installdir,/,pgm,.ucb); fi; exit 0 @@\
+       $(INSTALLSUID) pgm concat4(${DESTDIR},installdir,/,pgm)         @@\
+                                                                       @@\
+clean::                                                                @@\
+       $(RM) pgm objs                                                  @@\
+
+
 /*
  * Rule for installing man pages.  Section installing into should match
  * suffix, or the man page won't show up when using man(1).
@@ -258,7 +351,7 @@ clean::                                                             @@\
 #define manpage(section,page)                                          @@\
 all::                                                                  @@\
 install:: page                                                         @@\
-       $(INSTALLFILE) page concat3(${DESTDIR}${MANDIR}/man,section,/`basename page`) @@\
+       $(INSTALLFILE) page concat4(${DESTDIR}${MANDIR}/man,section,/,`basename page`) @@\
 
 /*
  * Rule for building makefile dependencies.
@@ -299,6 +392,7 @@ print:: ${CODE}                                                             @@\
 src:: ${CODE}                                                          @@\
                                                                        @@\
 ${CODE}:                                                               @@\
+       $(RM) $@                                                        @@\
        -$(LN) ${SRCDIR}/$@ $@
 
 #define do_subdirs_no_imakefile(subdirs)                               @@\
This page took 0.043888 seconds and 4 git commands to generate.