-SubDir PDCLIB_TOP ;\r
-if $(PDCLIB_PLATFORM) {\r
- SubInclude PDCLIB_TOP platform $(PDCLIB_PLATFORM) ;\r
- SubDir PDCLIB_TOP ;\r
-}\r
-PDCLibConfig ;\r
-\r
-PDCLIB_SOURCES = [ RecursiveGlob $(PDCLIB_TOP) : [ FDirName functions ] : *.c ] ;\r
-\r
-if $(PDCLIB_PLATFORM) {\r
- PDCLIB_PLATFORM_SOURCE_DIR = \r
- [ FDirName platform $(PDCLIB_PLATFORM) functions ] ;\r
- PDCLIB_SOURCES += [ RecursiveGlob $(PDCLIB_TOP) : $(PDCLIB_PLATFORM_SOURCE_DIR) : *.c ] ;\r
-}\r
-\r
-for opt in $(PDCLIB_OPTIONS) {\r
- optdir = [ FDirName opt $(opt) ] ;\r
- PDCLIB_SOURCES += [ RecursiveGlob $(PDCLIB_TOP) : $(optdir) : *.c ] ; \r
-}\r
-\r
-Library $(PDCLIB) : $(PDCLIB_SOURCES) ;\r
-\r
-if ! $(PDCLIB_NO_TEST) {\r
- for file in $(PDCLIB_SOURCES) {\r
- testfile = $(file:S=_t) ;\r
- regtestfile = $(file:S=_r) ;\r
- test = $(file:S=-test) ;\r
- regtest = $(file:S=-regtest) ;\r
-\r
- Object $(testfile).o : $(file) ;\r
- MainFromObjects $(testfile) : $(testfile).o $(CRT0) ;\r
- CCFLAGS on $(testfile).o += -DTEST $(PDCLIB_TEST_CCFLAGS) ;\r
- LINKFLAGS on $(testfile)$(SUFEXE) += $(PDCLIB_TEST_LINKFLAGS) ;\r
- LINKLIBS on $(testfile)$(SUFEXE) += $(PDCLIB_TEST_LINKLIBS) ;\r
- LinkLibraries $(testfile) : $(PDCLIB) ;\r
- Test $(test) : $(testfile) ;\r
-\r
- if ! $(PDCLIB_NO_REGTEST) {\r
- Object $(regtestfile).o : $(file) ;\r
- MainFromObjects $(regtestfile) : $(regtestfile).o ;\r
- CCFLAGS on $(regtestfile).o += -DTEST -DREGTEST \r
- $(PDCLIB_REGTEST_CCFLAGS) ;\r
- CCHDRS on $(regtestfile).o = [ FIncludes [ FDirName testing ] ] $(PDCLIB_REGTEST_CCHDRS) ;\r
- LINKFLAGS on $(regtestfile)$(SUFEXE) += $(PDCLIB_REGTEST_LINKFLAGS) ;\r
- LINKLIBS on $(regtestfile)$(SUFEXE) += $(PDCLIB_REGTEST_LINKLIBS) ;\r
- RegTest $(regtest) : $(regtestfile) ;\r
- }\r
- }\r
-}\r
-\r
-rule HtmlMan { \r
- DEPENDS htmlman : $(<) ;\r
- DEPENDS $(<) : $(<:D) ;\r
- DEPENDS $(<) : $(>) ;\r
- MkDir $(<:D) ;\r
-}\r
-\r
-actions HtmlMan {\r
- mandoc -Thtml -Oincludes=../3/%I.html -Oman=../%S/%N.html -Ostyle=../style.css $(>) >$(<)\r
-}\r
-\r
-for manpg in [ GLOB man3 : *.3 ] {\r
- local section = [ SPLIT $(manpg:S) : . ] ;\r
- HtmlMan [ FDirName html $(section) $(manpg:B).html ] : $(manpg) ;\r
+SubDir PDCLIB_TOP ;
+if $(PDCLIB_PLATFORM) {
+ SubInclude PDCLIB_TOP platform $(PDCLIB_PLATFORM) ;
+ SubDir PDCLIB_TOP ;
+}
+PDCLibConfig ;
+
+PDCLIB_SOURCES = [ RecursiveGlob $(PDCLIB_TOP) : [ FDirName functions ] : *.c ] ;
+
+if $(PDCLIB_PLATFORM) {
+ PDCLIB_PLATFORM_SOURCE_DIR =
+ [ FDirName platform $(PDCLIB_PLATFORM) functions ] ;
+ PDCLIB_SOURCES += [ RecursiveGlob $(PDCLIB_TOP) : $(PDCLIB_PLATFORM_SOURCE_DIR) : *.c ] ;
+}
+
+for opt in $(PDCLIB_OPTIONS) {
+ optdir = [ FDirName opt $(opt) ] ;
+ PDCLIB_SOURCES += [ RecursiveGlob $(PDCLIB_TOP) : $(optdir) : *.c ] ;
+}
+
+Library $(PDCLIB) : $(PDCLIB_SOURCES) ;
+
+if ! $(PDCLIB_NO_TEST) {
+ for file in $(PDCLIB_SOURCES) {
+ testfile = $(file:S=_t) ;
+ regtestfile = $(file:S=_r) ;
+ test = $(file:S=-test) ;
+ regtest = $(file:S=-regtest) ;
+
+ Object $(testfile).o : $(file) ;
+ MainFromObjects $(testfile) : $(testfile).o $(CRT0) ;
+ CCFLAGS on $(testfile).o += -DTEST $(PDCLIB_TEST_CCFLAGS) ;
+ LINKFLAGS on $(testfile)$(SUFEXE) += $(PDCLIB_TEST_LINKFLAGS) ;
+ LINKLIBS on $(testfile)$(SUFEXE) += $(PDCLIB_TEST_LINKLIBS) ;
+ LinkLibraries $(testfile) : $(PDCLIB) ;
+ Test $(test) : $(testfile) ;
+
+ if ! $(PDCLIB_NO_REGTEST) {
+ Object $(regtestfile).o : $(file) ;
+ MainFromObjects $(regtestfile) : $(regtestfile).o ;
+ CCFLAGS on $(regtestfile).o += -DTEST -DREGTEST
+ $(PDCLIB_REGTEST_CCFLAGS) ;
+ CCHDRS on $(regtestfile).o = [ FIncludes [ FDirName testing ] ] $(PDCLIB_REGTEST_CCHDRS) ;
+ LINKFLAGS on $(regtestfile)$(SUFEXE) += $(PDCLIB_REGTEST_LINKFLAGS) ;
+ LINKLIBS on $(regtestfile)$(SUFEXE) += $(PDCLIB_REGTEST_LINKLIBS) ;
+ RegTest $(regtest) : $(regtestfile) ;
+ }
+ }
+}
+
+Main helloworld : helloworld.c ;
+LinkLibraries helloworld : $(PDCLIB) ;
+
+rule HtmlMan {
+ DEPENDS htmlman : $(<) ;
+ DEPENDS $(<) : $(<:D) ;
+ DEPENDS $(<) : $(>) ;
+ MkDir $(<:D) ;
+}
+
+actions HtmlMan {
+ mandoc -Thtml -Oincludes=../3/%I.html -Oman=../%S/%N.html -Ostyle=../style.css $(>) >$(<)
+}
+
+for manpg in [ GLOB man3 : *.3 ] {
+ local section = [ SPLIT $(manpg:S) : . ] ;
+ HtmlMan [ FDirName html $(section) $(manpg:B).html ] : $(manpg) ;
}
\ No newline at end of file
-PDCLIB ?= pdclib ;\r
-\r
-ECHO "PDCLIB_TOP: " $(PDCLIB_TOP) ;\r
-\r
-if ! $(PDCLIB_HAVE_PLATFORM) && ! $(PDCLIB_PLATFORM) {\r
- if $(NT) {\r
- PDCLIB_PLATFORM = "win32" ;\r
- } else if $(UNIX) {\r
- PDCLIB_PLATFORM = "posix" ;\r
- } else {\r
- ECHO PDCLIB_PLATFORM not set and platform not automatically detected ;\r
- ECHO Set PDCLIB_PLATFORM to the platform to be built for ;\r
- EXIT ;\r
- }\r
- PDCLIB_HAVE_PLATFORM = 1 ;\r
-}\r
-\r
-if $(PDCLIB_TOOLCHAIN) = "" {\r
- local __ccparts = [ SPLIT $(CC) : "-" ] ;\r
- if $(JAM_TOOLSET) = "MINGW" || "gcc" in $(__ccparts) \r
- || "clang" in $(__ccparts) {\r
- # GCC / GCC-alike\r
- PDCLIB_TOOLCHAIN = "gcc" ;\r
- } else if $(JAM_TOOLSET) != "" {\r
- PDCLIB_TOOLCHAIN = $(JAM_TOOLSET) ;\r
- } else {\r
- ECHO PDCLIB_TOOLCHAIN is unset and I can't glean what toolset is being ;\r
- ECHO used from your environment. Please set it. ;\r
- EXIT ;\r
- }\r
-}\r
-\r
-if $(PDCLIB_TOOLCHAIN) = "gcc" {\r
- # No -Wcast-align : spurious warnings when using char* to do pointer \r
- # arithmetic\r
- # No -Winline : when compiling with e.g. -Os causes spurious \r
- # warnings that call is unlikely/code size would grow\r
- # No -Wredundant-decls : some functions must be multiply defined\r
- PDCLIB_WARNINGS ?= \r
- -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow \r
- -Wpointer-arith -Wwrite-strings -Wmissing-declarations -Wno-long-long \r
- -Wuninitialized \r
- ;\r
- PDCLIB_CCWARNINGS ?= \r
- -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes ;\r
- PDCLIB_CCFLAGS = \r
- -ffreestanding \r
- #-nostdinc \r
- -std=c11 \r
- -g \r
- -D_PDCLIB_BUILD\r
- $(PDCLIB_WARNINGS) ;\r
- PDCLIB_C++FLAGS =\r
- -ffreestanding\r
- #-nostdinc\r
- -std=c++11\r
- -g\r
- -D_PDCLIB_BUILD\r
- $(PDCLIB_WARNINGS) ;\r
-\r
- actions Link bind NEEDLIBS\r
- {\r
- $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) -Wl,--start-group $(NEEDLIBS) $(LINKLIBS) -Wl,--end-group\r
- }\r
-} else if $(PDCLIB_TOOLCHAIN) = "WATCOM" {\r
- ECHO "Watcom!" ;\r
- CCFLAGS = /zq /DWIN32 /zls ;\r
- C++FLAGS = /zq /DWIN32 /zls ;\r
- STDHDRS = $(WATCOM)\\h\\nt ;\r
- PDCLIB_CCFLAGS = "-za99 -zl -s" ;\r
-} else {\r
- ECHO The value of PDCLIB_TOOLCHAIN is not recognized ;\r
- ECHO Currently set to $(PDCLIB_TOOLCHAIN) ;\r
- EXIT ;\r
-}\r
-\r
-if $(PDCLIB_PLATFORM) {\r
- include [ FDirName $(PDCLIB_TOP) platform $(PDCLIB_PLATFORM) Config.jam ] ;\r
-}\r
-\r
-rule PDCLibHeaders {\r
- SubDirHdrs $(PDCLIB_TOP) includes ;\r
- SubDirHdrs $(PDCLIB_TOP) internals ;\r
- SubDirHdrs $(PDCLIB_TOP) testing ;\r
- for opt in $(PDCLIB_OPTIONS) {\r
- SubDirHdrs $(PDCLIB_TOP) opt $(opt) ;\r
- }\r
- PDCLibTargetHeaders ;\r
-}\r
-\r
-rule PDCLibConfig {\r
- SubDirCcFlags $(PDCLIB_CCFLAGS) ;\r
- SubDirC++Flags $(PDCLIB_C++FLAGS) ;\r
- PDCLibHeaders ;\r
- PDCLibTargetConfig ;\r
-}\r
-\r
-# MinGW needs appropriate prodding to cretae executables\r
-if $(TOOLSET) = MINGW {\r
- PDCLIB_TEST_LINKFLAGS += -mconsole ;\r
- PDCLIB_REGTEST_LINKFLAGS += -mconsole ;\r
-}\r
-\r
-# Tests\r
-ALWAYS regtest test ;\r
-\r
-rule Test {\r
- DEPENDS $(<) : $(>) ;\r
- ALWAYS $(<) ;\r
- DEPENDS test : $(<) ;\r
-}\r
-\r
-rule RegTest {\r
- DEPENDS $(<) : $(>) ;\r
- ALWAYS $(<) ;\r
- DEPENDS regtest : $(<) ;\r
-}\r
-\r
-actions Test {\r
- $(>)\r
-}\r
-\r
-actions RegTest {\r
- $(>)\r
-}\r
-\r
-# list all files in a directory, except ., ..\r
-# [ ListDir base : dirname ]\r
-rule ListDir {\r
- # start with empty list\r
- local _result = ;\r
-\r
- # for each file in the directory\r
- local _dirlist = [ GLOB [ FDirName $(1) $(2) ] : * ] ;\r
- for _subdir in $(_dirlist) {\r
-\r
- # if it is not . or ..\r
- switch $(_subdir) {\r
- case *\\. : _dummy = "" ; # is there some no-op statement?\r
- case *\\.. : _dummy = "" ; # is there some no-op statement?\r
- case * :\r
- # add it to the list\r
- _result += $(_subdir:D=$(2)) ;\r
- }\r
- }\r
-\r
- # return resulting list\r
- return $(_result) ;\r
-}\r
-\r
-# same as glob, but recurses into subdirs\r
-rule RecursiveGlob {\r
- # initially use the files in the current directory\r
- local _dir = $(2) ;\r
- local _path = [ FDirName $(1) $(2) ] ;\r
- local _result = [ GLOB $(_path) : $(3) ] ;\r
- _result = $(_result:D=$(_dir)) ;\r
-\r
- # list all subdirectories (and files, but it doesn't hurt)\r
- local _subdirlist = [ ListDir $(1) : $(2) ] ;\r
-\r
- # for each subdir/file\r
- for _subdir in $(_subdirlist) {\r
- # recurse into it\r
- _result += [ RecursiveGlob $(1) : $(_subdir) : $(3) ] ;\r
- }\r
-\r
- # return the resulting list\r
- return $(_result) ;\r
-}\r
-\r
-# Fix to work on targets in subdirs\r
-rule MakeLocate\r
-{\r
- # Note we grist the directory name with 'dir',\r
- # so that directory path components and other\r
- # targets don't conflict.\r
-\r
- if $(>)\r
- {\r
- local _rev = [ FReverse $(>) ] ;\r
- if $(_rev[1]) = "." {\r
- _rev = $(_rev[2-]) ;\r
- } \r
- local _dir = [ FDirName [ FReverse $(_rev) ] $(<[0]:D) ] ;\r
-\r
- LOCATE on $(<) = [ FDirName $(>) ] ;\r
- Depends $(<) : $(_dir:G=dir) ;\r
- MkDir $(_dir:G=dir) ;\r
- }\r
+PDCLIB ?= pdclib ;
+
+ECHO "PDCLIB_TOP: " $(PDCLIB_TOP) ;
+
+if ! $(PDCLIB_HAVE_PLATFORM) && ! $(PDCLIB_PLATFORM) {
+ if $(NT) {
+ PDCLIB_PLATFORM = "win32" ;
+ } else if $(UNIX) {
+ PDCLIB_PLATFORM = "posix" ;
+ } else {
+ ECHO PDCLIB_PLATFORM not set and platform not automatically detected ;
+ ECHO Set PDCLIB_PLATFORM to the platform to be built for ;
+ EXIT ;
+ }
+ PDCLIB_HAVE_PLATFORM = 1 ;
+}
+
+if $(PDCLIB_TOOLCHAIN) = "" {
+ local __ccparts = [ SPLIT $(CC) : "-" ] ;
+ if $(JAM_TOOLSET) = "MINGW" || "gcc" in $(__ccparts)
+ || "clang" in $(__ccparts) {
+ # GCC / GCC-alike
+ PDCLIB_TOOLCHAIN = "gcc" ;
+ } else if $(JAM_TOOLSET) != "" {
+ PDCLIB_TOOLCHAIN = $(JAM_TOOLSET) ;
+ } else {
+ ECHO PDCLIB_TOOLCHAIN is unset and I can't glean what toolset is being ;
+ ECHO used from your environment. Please set it. ;
+ EXIT ;
+ }
+}
+
+if $(PDCLIB_TOOLCHAIN) = "gcc" {
+ # No -Wcast-align : spurious warnings when using char* to do pointer
+ # arithmetic
+ # No -Winline : when compiling with e.g. -Os causes spurious
+ # warnings that call is unlikely/code size would grow
+ # No -Wredundant-decls : some functions must be multiply defined
+ PDCLIB_WARNINGS ?=
+ -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow
+ -Wpointer-arith -Wwrite-strings -Wmissing-declarations -Wno-long-long
+ -Wuninitialized
+ ;
+ PDCLIB_CCWARNINGS ?=
+ -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes ;
+ PDCLIB_CCFLAGS =
+ -ffreestanding
+ #-nostdinc
+ -std=c11
+ -g
+ -D_PDCLIB_BUILD
+ $(PDCLIB_WARNINGS) ;
+ PDCLIB_C++FLAGS =
+ -ffreestanding
+ #-nostdinc
+ -std=c++11
+ -g
+ -D_PDCLIB_BUILD
+ $(PDCLIB_WARNINGS) ;
+
+ if $(OS) = "MACOSX" {
+ # ld64 does automatic repeated searches of archives
+ # and doesn't accept --start-group/--end-group
+
+ #actions Link bind NEEDLIBS
+ #{
+ # $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
+ #}
+ } else {
+ actions Link bind NEEDLIBS
+ {
+ $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) -Wl,--start-group $(NEEDLIBS) $(LINKLIBS) -Wl,--end-group
+ }
+ }
+} else if $(PDCLIB_TOOLCHAIN) = "WATCOM" {
+ ECHO "Watcom!" ;
+ CCFLAGS = /zq /DWIN32 /zls ;
+ C++FLAGS = /zq /DWIN32 /zls ;
+ STDHDRS = $(WATCOM)\\h\\nt ;
+ PDCLIB_CCFLAGS = "-za99 -zl -s" ;
+} else {
+ ECHO The value of PDCLIB_TOOLCHAIN is not recognized ;
+ ECHO Currently set to $(PDCLIB_TOOLCHAIN) ;
+ EXIT ;
+}
+
+if $(PDCLIB_PLATFORM) {
+ include [ FDirName $(PDCLIB_TOP) platform $(PDCLIB_PLATFORM) Config.jam ] ;
+}
+
+rule PDCLibHeaders {
+ SubDirHdrs $(PDCLIB_TOP) includes ;
+ SubDirHdrs $(PDCLIB_TOP) internals ;
+ SubDirHdrs $(PDCLIB_TOP) testing ;
+ for opt in $(PDCLIB_OPTIONS) {
+ SubDirHdrs $(PDCLIB_TOP) opt $(opt) ;
+ }
+ PDCLibTargetHeaders ;
+}
+
+rule PDCLibConfig {
+ SubDirCcFlags $(PDCLIB_CCFLAGS) ;
+ SubDirC++Flags $(PDCLIB_C++FLAGS) ;
+ PDCLibHeaders ;
+ PDCLibTargetConfig ;
+}
+
+# MinGW needs appropriate prodding to cretae executables
+if $(TOOLSET) = MINGW {
+ PDCLIB_TEST_LINKFLAGS += -mconsole ;
+ PDCLIB_REGTEST_LINKFLAGS += -mconsole ;
+}
+
+# Tests
+ALWAYS regtest test ;
+
+rule Test {
+ DEPENDS $(<) : $(>) ;
+ ALWAYS $(<) ;
+ DEPENDS test : $(<) ;
+}
+
+rule RegTest {
+ DEPENDS $(<) : $(>) ;
+ ALWAYS $(<) ;
+ DEPENDS regtest : $(<) ;
+}
+
+actions Test {
+ $(>)
+}
+
+actions RegTest {
+ $(>)
+}
+
+# list all files in a directory, except ., ..
+# [ ListDir base : dirname ]
+rule ListDir {
+ # start with empty list
+ local _result = ;
+
+ # for each file in the directory
+ local _dirlist = [ GLOB [ FDirName $(1) $(2) ] : * ] ;
+ for _subdir in $(_dirlist) {
+
+ # if it is not . or ..
+ switch $(_subdir) {
+ case *\\. : _dummy = "" ; # is there some no-op statement?
+ case *\\.. : _dummy = "" ; # is there some no-op statement?
+ case * :
+ # add it to the list
+ _result += $(_subdir:D=$(2)) ;
+ }
+ }
+
+ # return resulting list
+ return $(_result) ;
+}
+
+# same as glob, but recurses into subdirs
+rule RecursiveGlob {
+ # initially use the files in the current directory
+ local _dir = $(2) ;
+ local _path = [ FDirName $(1) $(2) ] ;
+ local _result = [ GLOB $(_path) : $(3) ] ;
+ _result = $(_result:D=$(_dir)) ;
+
+ # list all subdirectories (and files, but it doesn't hurt)
+ local _subdirlist = [ ListDir $(1) : $(2) ] ;
+
+ # for each subdir/file
+ for _subdir in $(_subdirlist) {
+ # recurse into it
+ _result += [ RecursiveGlob $(1) : $(_subdir) : $(3) ] ;
+ }
+
+ # return the resulting list
+ return $(_result) ;
+}
+
+# Fix to work on targets in subdirs
+rule MakeLocate
+{
+ # Note we grist the directory name with 'dir',
+ # so that directory path components and other
+ # targets don't conflict.
+
+ if $(>)
+ {
+ local _rev = [ FReverse $(>) ] ;
+ if $(_rev[1]) = "." {
+ _rev = $(_rev[2-]) ;
+ }
+ local _dir = [ FDirName [ FReverse $(_rev) ] $(<[0]:D) ] ;
+
+ LOCATE on $(<) = [ FDirName $(>) ] ;
+ Depends $(<) : $(_dir:G=dir) ;
+ MkDir $(_dir:G=dir) ;
+ }
}
\ No newline at end of file