Skip to content

Commit 018bfd6

Browse files
committed
Refactor build system with GNUmakefile and autotools
- Replace bootstrap script with GNUmakefile for automatic build generation - Configure libtool with disable-static by default (use --enable-static to enable) - Fix Makefile.am to remove non-existent Windows source reference - Remove all prebuilt static libraries from repository - Add distclean target to remove all generated files
1 parent ad9f07c commit 018bfd6

16 files changed

Lines changed: 126 additions & 40 deletions

File tree

GNUmakefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
PREFIX ?= /usr/local
2+
3+
GENERATED_MAKEFILE := $(wildcard Makefile)
4+
5+
.PHONY: distclean
6+
distclean:
7+
@if [ -f Makefile ]; then \
8+
echo "Running make distclean..."; \
9+
$(MAKE) -f Makefile distclean 2>/dev/null || true; \
10+
fi
11+
@echo "Removing autotools generated files..."
12+
@rm -rf Makefile Makefile.in configure config.* libtool aclocal.m4 stamp-h1 autom4te.cache
13+
@rm -rf compile config.guess config.sub depcomp install-sh ltmain.sh missing
14+
@rm -rf .libs .deps src/.libs src/.deps
15+
@rm -f *.lo *.la src/*.lo src/*.la
16+
@echo "All generated files removed. Run 'make' to rebuild."
17+
18+
# If Makefile exists, delegate to it
19+
ifneq ($(GENERATED_MAKEFILE),)
20+
21+
.DEFAULT_GOAL := all
22+
23+
%:
24+
$(MAKE) -f Makefile $@
25+
26+
else
27+
28+
# No Makefile - need to generate build system
29+
.DEFAULT_GOAL := all
30+
31+
configure: configure.ac Makefile.am
32+
@echo "Generating build system..."
33+
@which glibtoolize > /dev/null 2>&1 && glibtoolize --copy --force --quiet || libtoolize --copy --force --quiet
34+
@aclocal
35+
@autoheader
36+
@automake --add-missing --copy --foreign
37+
@autoconf
38+
@echo ""
39+
40+
Makefile: configure
41+
@echo "Running configure..."
42+
@./configure --prefix=$(PREFIX)
43+
@echo ""
44+
45+
.PHONY: all
46+
all: Makefile
47+
@$(MAKE) -f Makefile all
48+
@echo ""
49+
@echo "Build complete. Install with: make install"
50+
@echo ""
51+
52+
.PHONY: build
53+
build: all
54+
55+
.PHONY: install
56+
install: Makefile
57+
@$(MAKE) -f Makefile install
58+
59+
.PHONY: clean
60+
clean: Makefile
61+
@$(MAKE) -f Makefile clean
62+
63+
endif

Makefile.am

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
pkglib_LTLIBRARIES = libasyncprocess.la
2-
libasyncprocess_la_LDFLAGS = -module -avoid-version -no-undefined
3-
libasyncprocess_la_SOURCES = src/async-process.c src/async-process_windows.c
1+
lib_LTLIBRARIES = libasyncprocess.la
2+
libasyncprocess_la_LDFLAGS = -version-info 0:0:0 -no-undefined
3+
libasyncprocess_la_SOURCES = src/async-process.c
44

5-
copy:
6-
$(MKDIR_P) static/`uname -m`/`uname`
7-
cp -f .libs/libasyncprocess.so static/`uname -m`/`uname`/libasyncprocess.so|true
8-
cp -f .libs/libasyncprocess.dylib static/`uname -m`/`uname`/libasyncprocess.dylib|true
9-
case "$(MSYSTEM)" in \
10-
MINGW32) \
11-
$(MKDIR_P) static/x86/windows ;\
12-
cp -f .libs/libasyncprocess.dll static/x86/windows/libasyncprocess.dll|true;; \
13-
*) \
14-
$(MKDIR_P) static/`uname -m`/windows ;\
15-
cp -f .libs/libasyncprocess.dll static/`uname -m`/windows/libasyncprocess.dll|true;; \
16-
esac
5+
include_HEADERS = src/async-process.h
6+
7+
install-exec-hook:
8+
rm -f $(DESTDIR)$(libdir)/libasyncprocess.la

bootstrap

Lines changed: 0 additions & 10 deletions
This file was deleted.

cleanup-all

Lines changed: 0 additions & 11 deletions
This file was deleted.

configure.ac

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
11
AC_INIT([async-process], [0.1])
2-
AM_CONFIG_HEADER(config.h)
2+
AC_CONFIG_HEADERS([config.h])
33

4-
AM_INIT_AUTOMAKE([foreign])
5-
LT_INIT(shared win32-dll)
4+
# Set default prefix based on platform if not specified
5+
AC_PREFIX_DEFAULT([/usr/local])
6+
7+
AM_INIT_AUTOMAKE([foreign subdir-objects])
8+
9+
# Must detect C compiler before initializing libtool
610
AC_PROG_CC
711

12+
# Initialize libtool (disable static by default, enable with --enable-static)
13+
LT_INIT([disable-static])
14+
15+
# Platform-specific configuration
16+
AC_CANONICAL_HOST
17+
case $host_os in
18+
freebsd*)
19+
# FreeBSD typically uses /usr/local
20+
test "$prefix" = NONE && prefix=/usr/local
21+
;;
22+
darwin*)
23+
# macOS typically uses /usr/local
24+
test "$prefix" = NONE && prefix=/usr/local
25+
;;
26+
linux*)
27+
# Linux typically uses /usr/local for user-installed software
28+
test "$prefix" = NONE && prefix=/usr/local
29+
;;
30+
esac
831

9-
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h windows.h])
32+
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
1033

1134
AC_CHECK_HEADER_STDBOOL
1235
AC_TYPE_PID_T
@@ -17,3 +40,32 @@ AC_CHECK_FUNCS([dup2 strerror])
1740

1841
AC_CONFIG_FILES([Makefile])
1942
AC_OUTPUT
43+
44+
# Print configuration summary
45+
AC_MSG_NOTICE([
46+
async-process configuration summary:
47+
48+
Installation prefix: $prefix
49+
Library directory: $libdir
50+
Include directory: $includedir
51+
C Compiler: $CC
52+
Host system: $host_os
53+
Build shared: $enable_shared
54+
Build static: $enable_static
55+
56+
Note: This C library is for Unix-like systems only (Linux, FreeBSD, macOS).
57+
Windows support is provided via pure Lisp CFFI implementation and does not
58+
require C compilation.
59+
60+
You can now run 'make' to build the library.
61+
After building, run 'make install' to install to the prefix.
62+
63+
To install to a different location, reconfigure with:
64+
./configure --prefix=/your/custom/path
65+
66+
To build static library:
67+
./configure --enable-static
68+
69+
To build only static (no shared):
70+
./configure --enable-static --disable-shared
71+
])
-24.8 KB
Binary file not shown.
-25.9 KB
Binary file not shown.
-51.1 KB
Binary file not shown.
-14.6 KB
Binary file not shown.
-28.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)