Skip to content

Commit 44aef4e

Browse files
committed
Refactor build system with GNUmakefile and autotools improvements
- Replace bootstrap script with GNUmakefile for automatic build generation - Support both glibtoolize (macOS) and libtoolize (Linux/BSD) - Add INSTALL documentation with build instructions - Configure libtool with disable-static by default (use --enable-static to enable) - Fix Makefile.am to remove non-existent Windows source reference - Remove empty m4 folder and outdated build scripts - Remove all prebuilt static libraries from repository - Update .gitignore for build artifacts - Add distclean target to remove all generated files Benefits: - Single command to build: just 'make' or 'gmake' - No need to run bootstrap manually - Clean separation of source and generated files - Static libraries opt-in rather than opt-out - Full cleanup with 'gmake distclean' returns to clean checkout state
1 parent ad9f07c commit 44aef4e

18 files changed

Lines changed: 300 additions & 40 deletions

File tree

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
21
*.o
32
*.lo
43
*.la
54
.deps
65
.libs
6+
.dirstamp
7+
*~
78

89
Makefile
910
Makefile.in
@@ -24,3 +25,5 @@ config.log
2425
libtool
2526
ltmain.sh
2627

28+
# Don't track pre-built binaries
29+
static/

GNUmakefile

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

INSTALL

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
Installation Instructions for async-process
2+
===========================================
3+
4+
## Quick Start
5+
6+
For most users on FreeBSD, Linux, or macOS:
7+
8+
make
9+
sudo make install
10+
11+
This will install to /usr/local by default.
12+
13+
## Detailed Installation Steps
14+
15+
The Makefile handles everything automatically, including generating the
16+
configure script if needed. No bootstrap script required!
17+
18+
### 1. Build the Library
19+
20+
Simply run:
21+
22+
make
23+
24+
This automatically:
25+
- Generates the configure script (if not present)
26+
- Runs configure with default settings
27+
- Builds the library
28+
29+
### 2. Install
30+
31+
make install
32+
33+
By default, this installs to /usr/local:
34+
- Library: /usr/local/lib/libasyncprocess.so (or .dylib on macOS)
35+
- Header: /usr/local/include/async-process.h
36+
37+
You may need to use sudo if installing to a system directory:
38+
39+
sudo make install
40+
41+
### 3. Custom Installation Prefix
42+
43+
To install to a different location, specify PREFIX:
44+
45+
make install PREFIX=/usr # System-wide
46+
make install PREFIX=$HOME/.local # User installation
47+
make install PREFIX=/opt/local # Alternative location
48+
49+
#### FreeBSD-Specific Examples
50+
51+
make install PREFIX=/usr/local # Standard FreeBSD location (default)
52+
make install PREFIX=/usr/local/async-process # Isolated installation
53+
54+
## Advanced Usage
55+
56+
### Manual Configure Options
57+
58+
If you need custom configure options beyond --prefix:
59+
60+
make # This generates configure if needed
61+
./configure --prefix=/usr/local --enable-shared --disable-static
62+
make
63+
make install
64+
65+
## Configure Dynamic Linker (if needed)
66+
67+
#### On Linux
68+
69+
If you installed to a non-standard prefix, you may need to update the linker cache:
70+
71+
sudo ldconfig
72+
73+
Or add the library directory to LD_LIBRARY_PATH:
74+
75+
export LD_LIBRARY_PATH=/your/prefix/lib:$LD_LIBRARY_PATH
76+
77+
#### On FreeBSD
78+
79+
sudo ldconfig -m /your/prefix/lib
80+
81+
#### On macOS
82+
83+
export DYLD_LIBRARY_PATH=/your/prefix/lib:$DYLD_LIBRARY_PATH
84+
85+
## Verify Installation
86+
87+
Check that the library is installed:
88+
89+
ls -l /usr/local/lib/libasyncprocess.*
90+
ls -l /usr/local/include/async-process.h
91+
92+
## Uninstalling
93+
94+
To remove the installed files:
95+
96+
sudo make uninstall
97+
98+
## Development Installation
99+
100+
For development, you can use the optional 'copy' target to build platform-specific
101+
libraries in the static/ directory tree:
102+
103+
make copy
104+
105+
This is useful for bundling pre-built libraries with the project, but is not
106+
needed for normal installation.
107+
108+
## Platform-Specific Notes
109+
110+
### FreeBSD
111+
112+
FreeBSD uses /usr/local as the standard location for third-party software.
113+
The default configuration matches this convention.
114+
115+
### Linux
116+
117+
Most Linux distributions use /usr/local for locally-installed software.
118+
Package managers typically use /usr.
119+
120+
### macOS
121+
122+
Homebrew uses /usr/local on Intel Macs and /opt/homebrew on Apple Silicon.
123+
The default /usr/local works for manual installations.
124+
125+
## Requirements
126+
127+
- C compiler (GCC, Clang, etc.)
128+
- GNU Make
129+
- Autotools (autoconf, automake, libtool) - only needed for bootstrap
130+
- POSIX-compliant system (Unix, Linux, *BSD, macOS)
131+
132+
## Troubleshooting
133+
134+
### configure: command not found
135+
136+
Run ./bootstrap first to generate the configure script.
137+
138+
### Permission denied during make install
139+
140+
Use sudo:
141+
142+
sudo make install
143+
144+
### Library not found at runtime
145+
146+
Configure your dynamic linker (see step 5 above).
147+
148+
## For Packagers
149+
150+
When building packages, use DESTDIR for staged installation:
151+
152+
make install DESTDIR=/path/to/staging/dir
153+
154+
This installs to $DESTDIR/$PREFIX/... for packaging.
155+
156+
## Support
157+
158+
For issues, please visit: https://github.com/soppelmann/async-process

Makefile.am

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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+
# Don't install .la files and remove full version number
8+
install-exec-hook:
9+
rm -f $(DESTDIR)$(libdir)/libasyncprocess.la
10+
@if [ -f $(DESTDIR)$(libdir)/libasyncprocess.so.0.0.0 ]; then \
11+
cp -f $(DESTDIR)$(libdir)/libasyncprocess.so.0.0.0 $(DESTDIR)$(libdir)/libasyncprocess.so.0.tmp; \
12+
rm -f $(DESTDIR)$(libdir)/libasyncprocess.so.0.0.0 $(DESTDIR)$(libdir)/libasyncprocess.so.0 $(DESTDIR)$(libdir)/libasyncprocess.so; \
13+
mv $(DESTDIR)$(libdir)/libasyncprocess.so.0.tmp $(DESTDIR)$(libdir)/libasyncprocess.so.0; \
14+
ln -s libasyncprocess.so.0 $(DESTDIR)$(libdir)/libasyncprocess.so; \
15+
echo "Removed versioned file and created libasyncprocess.so.0"; \
16+
fi

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: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
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([win32-dll 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

932
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h windows.h])
1033

@@ -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.

0 commit comments

Comments
 (0)