| # Makefile of the Native C Library for Windows NT |
| # Copyright 2015-2026 Rivoreo |
| |
| # Permission is hereby granted, free of charge, to any person obtaining a copy |
| # of this software and associated documentation files (the "Software"), to |
| # deal in the Software without restriction, including without limitation the |
| # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| # sell copies of the Software, and to permit persons to whom the Software is |
| # furnished to do so, subject to the following conditions: |
| |
| # The above copyright notice and this permission notice shall be included in |
| # all copies or substantial portions of the Software. |
| |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR |
| # IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| # SOFTWARE. |
| |
| |
| AR := i586-mingw32msvc-ar |
| CC := i586-mingw32msvc-gcc |
| LD := i586-mingw32msvc-ld |
| CFLAGS += -I include -I ../ntdll/include -Os -Wall |
| LDFLAGS += --shared -e _DllMainCRTStartup --enable-stdcall-fixup --subsystem 1 |
| |
| OBJECTS := \ |
| assert.o \ |
| calloc.o \ |
| char-io.o \ |
| ctype.o \ |
| environ.o \ |
| errno.o \ |
| getcwd.o \ |
| getopt.o \ |
| getpagesize.o \ |
| link.o \ |
| malloc.o \ |
| mkdir.o \ |
| qsort.o \ |
| readlink.o \ |
| rmdir.o \ |
| sleep.o \ |
| statfs.o \ |
| statvfs.o \ |
| symlink.o \ |
| unlink.o \ |
| posix-io/access.o \ |
| posix-io/chmod.o \ |
| posix-io/close.o \ |
| posix-io/creat.o \ |
| posix-io/dirent.o \ |
| posix-io/dup.o \ |
| posix-io/fsync.o \ |
| posix-io/isatty.o \ |
| posix-io/lseek.o \ |
| posix-io/open.o \ |
| posix-io/read.o \ |
| posix-io/stat.o \ |
| posix-io/truncate.o \ |
| posix-io/tty-fd.o \ |
| posix-io/write.o \ |
| process/abort.o \ |
| process/create-process.o \ |
| process/exit.o \ |
| process/fork.o \ |
| process/getpid.o \ |
| process/wait.o \ |
| stdio/perror.o \ |
| stdio/remove.o \ |
| stdio/rename.o \ |
| string/mbrtowc.o \ |
| string/strcasecmp.o \ |
| string/strdup.o \ |
| string/strerror.o \ |
| string/strncasecmp.o \ |
| string/strnlen.o \ |
| string/strtok.o \ |
| string/strtoimax.o \ |
| string/strtol.o \ |
| string/strtoll.o \ |
| string/wcrtomb.o \ |
| time/datetime.o \ |
| time/gettime.o \ |
| time/gettimeofday.o \ |
| time/settime.o \ |
| time/settimeofday.o \ |
| time/strftime.o \ |
| time/time.o \ |
| time/utimens.o \ |
| time/utimes.o |
| |
| first: c.dll |
| |
| c.dll: dllcrt.o $(OBJECTS) |
| $(LD) $(LDFLAGS) $^ -L . -l ntdll -l gcc -o $@ |
| |
| libc.a: $(OBJECTS) |
| $(AR) -r $@ $^ |
| |
| dllcrt.o: build-version.h |
| |
| build-version.h: |
| @[ -f ../.git/HEAD ] && version="`cut -c -7 \"../.git/\`sed 's/^ref: //' ../.git/HEAD\`\"`" || version="local build"; printf '#define PKGVERSION "%s"\n' "$$version" > $@ |
| @printf '#define BUILD_DATE "%s"\n' "`date -u '+%F %T'` UTC" >> $@ |
| |
| clean: |
| rm -f build-version.h dllcrt.o $(OBJECTS) libc.a c.dll |