mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-24 11:09:01 +08:00
Merge pull request #2022 from cesanta/win
Adopt Makefile for Windows. Update examples readme section
This commit is contained in:
commit
6700b373cd
@ -18,17 +18,9 @@ utilising Mongoose's built-in TCP/IP stack and network drivers.
|
||||
## How to build and run examples
|
||||
|
||||
The easiest way to start with Mongoose is to try to build and run examples.
|
||||
The required tools are: a C/C++ compiler, the `make` utility, and `git`.
|
||||
|
||||
You can follow these links for tutorials on how to install these tools on your platform of choice
|
||||
|
||||
- [GCC](http://mongoose.ws/tutorials/tools/#gcc), the GNU C/C++ compiler collection
|
||||
- On Windows, you might want to use "[Build Tools for Visual Studio](https://visualstudio.microsoft.com/downloads)" instead
|
||||
- [GNU make](http://mongoose.ws/tutorials/tools/#gnu-make)
|
||||
- [Git](http://mongoose.ws/tutorials/tools/#git)
|
||||
|
||||
Now, when all required tools are installed, start a terminal/command prompt,
|
||||
and download the Mongoose repository, go to the HTTP server example, build it, and run it:
|
||||
Follow the [Development Environment](/tutorials/tools) tutorial to setup your
|
||||
development environment: a C compiler, a `make` utility, and a `git` utility.
|
||||
Start a terminal / command prompt and execute the following commands:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/cesanta/mongoose
|
||||
@ -36,20 +28,12 @@ cd mongoose/examples/http-server
|
||||
make
|
||||
```
|
||||
|
||||
That's it! Now start your browser, and point it to http://localhost:8000
|
||||
The above commands download Mongoose Library source code, then go into the
|
||||
HTTP server example directory, and execute `make` command. It uses a
|
||||
`Makefile` configuration file which is present in every example directory.
|
||||
It builds an example executable and runs it.
|
||||
|
||||
> NOTE: if you want to build and run embedded examples too, such as
|
||||
> STM32 or Raspberry Pi RP2040 examples, install an extra tool - the ARM GCC
|
||||
> compiler:
|
||||
|
||||
- [ARM GCC](http://mongoose.ws/tutorials/tools/#arm-gcc)
|
||||
|
||||
> When done, you can build baremetal embedded examples:
|
||||
|
||||
```sh
|
||||
cd examples/stm32/nucleo-h743zi-baremetal
|
||||
make build
|
||||
```
|
||||
Now start your browser, and point it to http://localhost:8000
|
||||
|
||||
## 2-minute integration guide
|
||||
|
||||
|
@ -1,21 +1,28 @@
|
||||
PROG ?= example
|
||||
ROOT ?= $(realpath $(CURDIR)/../..)
|
||||
DEFS ?= -DMG_ENABLE_LINES=1 -DMG_ENABLE_IPV6=1 -DMG_ENABLE_SSI=1 -DMG_HTTP_DIRLIST_TIME=1
|
||||
CFLAGS ?= -I../.. -W -Wall $(DEFS) $(EXTRA)
|
||||
VCFLAGS = /nologo /W3 /O2 /I../.. $(DEFS) $(EXTRA) /link /incremental:no /machine:IX86
|
||||
VC98 = docker run -it --rm -e Tmp=. -v $(ROOT):$(ROOT) -w $(CURDIR) mdashnet/vc98
|
||||
SOURCES = main.c ../../mongoose.c # Source code files
|
||||
CFLAGS = -W -Wall -Wextra -g # Build options
|
||||
|
||||
# Mongoose build options. See https://mongoose.ws/documentation/#build-options
|
||||
CFLAGS += -I ../..
|
||||
CFLAGS += -DMG_HTTP_DIRLIST_TIME=1 -DMG_ENABLE_SSI=1
|
||||
CFLAGS += -DMG_ENABLE_LINES=1 -DMG_ENABLE_IPV6=1
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows settings. Assume MinGW compiler
|
||||
PROG ?= example.exe # Use .exe suffix for the binary
|
||||
CC = gcc # Use MinGW gcc compiler
|
||||
CFLAGS += -lws2_32 # Link against Winsock library
|
||||
DELETE = cmd /C del /Q /F /S # Command prompt command to delete files
|
||||
else
|
||||
# Mac, Linux
|
||||
PROG ?= example
|
||||
DELETE = rm -rf
|
||||
endif
|
||||
|
||||
all: $(PROG)
|
||||
$(RUN) ./$(PROG) $(ARGS)
|
||||
|
||||
$(PROG): main.c Makefile
|
||||
$(CC) ../../mongoose.c main.c -I../.. $(CFLAGS) -o $@
|
||||
|
||||
mongoose.exe: main.c
|
||||
$(VC98) wine cl ../../mongoose.c main.c $(VCFLAGS) ws2_32.lib /out:$@
|
||||
|
||||
mingw:
|
||||
gcc ../../mongoose.c main.c -I../.. -W -Wall $(DEFS) -D_POSIX_C_SOURCE=200000L -lws2_32 -o mongoose.exe
|
||||
$(PROG): $(SOURCES)
|
||||
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_EXTRA) -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(PROG) *.o *.dSYM *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb mongoose mongoose_* mongoose.*
|
||||
$(DELETE) $(PROG) *.o *.dSYM
|
||||
|
Loading…
Reference in New Issue
Block a user